/*******************************************************************************
 * Copyright (c) 2013 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package com.niannian.adapter;

import com.niannian.R;
import com.niannian.BaseActivity;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * @author ListDiaog适配器
 * 
 */
public class ListDialogAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	public String[] item;
	private Activity mActivity;

	public ListDialogAdapter(Activity mActivity2, String[] item) {
		this.mActivity = mActivity2;
		this.item = item;
		mInflater = LayoutInflater.from(mActivity);
	}

	@Override
	public int getCount() {
		return item.length;
	}

	@Override
	public Object getItem(int position) {
		return item[position];
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();

			convertView = mInflater.inflate(R.layout.list_dialog_item, null);
			holder.tv_dialog_item = (TextView) convertView.findViewById(R.id.tv_dialog_item);// 名字

			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.tv_dialog_item.setText(item[position]);// 设置名字

		return convertView;
	}

	class ViewHolder {
		TextView tv_dialog_item;
	}
}
